Xbasic

FTP_MakeCommandList Function

Syntax

Result as C = FTP_MakeCommandList(C folder, C address, C username, C password [, C ascii_extension_list])

Arguments

folderCharacter

Folder on local machine that contains the files to be transferred.

addressCharacter

FTP address of target computer.

usernameCharacter

User name for login purposes.

passwordCharacter

User password for login purposes.

ascii_extension_listCharacter

Default = "<default>". A CR-LF list of file extensions to treat as ASCII files during transfer. Files with extensions not included in this list are treated as binary.

If ascii_extension_list is set to <default>, the following extension list is used:

.txt
.htm
.html
.a5w
.a5i
.inc
.css
.csv
.js
.xml
.xslt
.style_info
.a5_wf_buttons

Returns

ResultCharacter

Returns the FTP commands to execute.

Description

Creates command script for use by ftp_script_run() to transfer all files in a folder and its subfolder.

Discussion

The FTP_MakeCommandList() function is a helper function for use with FTP_SCRIPT_RUN()to construct a FTP script to transfer all of the files in a folder (including all sub-folders). The script will generate the necessary commands to re-create the folder structure of the source folder on the FTP client.

Example

Assume that a folder (called 'folder1') on the local machine contains the following files:

c:\folder1\file1.txt
c:\folder1\file2.txt
c:\folder1\subfolder1\file3.txt
c:\folder1\subfolder2\file4.txt

To transfer these files to a remote machine.

'generate the commands necessary to transfer files in c:\folder1
cmd = FTP_MakeCommandList("c:\folder1","ftp.myaddress.com","myname","mypassword")

'execute the script
ftp_script_run("test",cmd,.f.)

If you examine the code in the cmd variable, you will see that the following FTP commands were generated:

connect|ftp.myaddress.com
onerror|error|Could not connect
login|myname|mypassword
onerror|error|Could not log in
mkdir|subfolder1
mkdir|subfolder2
put|c:\folder1\file1.txt|file1.txt
put|c:\folder1\file2.txt|file2.txt
cd|/
cd|subfolder1
put|c:\folder1\subfolder1\file3.txt|file3.txt
cd|/
cd|subfolder2
put|c:\folder1\subfolder2\file4.txt|file4.txt

FTP_MakeCommandList() recognizes files as either binary or ASCII and uses the appropriate transfer mode. The default list of files transferred as ASCII are:

  • .TXT
  • .HTM
  • .HTML
  • .A5W
  • .A5I
  • .INC
  • .CSS
  • .CSV
  • .JS
  • .XML
  • .XSLT
  • .STYLE_INFO
  • .A5_WF_BUTTONS

Additionally, this list of file types my be overridden using an optional fifth argument to the function call. This argument should be a CR-LF separated list of file extensions, and each extension must include the "."

If you want to specify file extensions that should be treated as ASCII in addition to the built-in types, the first line of your CR-LF list should be "+" (a plus sign). For example, the following function call adds .INI files as a recognized ASCII file type.

FTP_MakeCommandList("c:\files_to_upload","server.com","alpha","alphapass","+" + crlf() + ".ini")

In contrast, the following function call will recognize only .INI files as ASCII and the built-in types will be transferred as binary files.

FTP_MakeCommandList("c:\files_to_upload","server.com","alpha","alphapass",".ini")

See Also